#ifndef STLMODEL_H
#define STLMODEL_H

//#include <windows.h>
//#include <cstdio>
//#include <cstdlib>
#include <vector>
#include <string>
#include <fstream>
#include <iostream>

//#include <GL/gl.h>
//#include <GL/glu.h>
//#include "gl/glut.h"

using namespace std;

// Face class definition
class Face
{
public:
	Face(float *normal, float *v1, float *v2, float *v3)
	{
		for (int n=0; n < 3; ++n) {
			_normal[n] = normal[n];
			_v1[n] = v1[n]; _v2[n] = v2[n]; _v3[n] = v3[n];
			_centroid[n] = (v1[n] + v2[n] + v3[n])/3;
		}
	};
	
	float _normal[3];
	float _v1[3];
	float _v2[3];
	float _v3[3];
	float _centroid[3];
};

// STL model class definition
class STLModel
{
public:
	STLModel(const std::string& filename);
	STLModel(STLModel& model);
	~STLModel(void);

	unsigned numFaces() {return (unsigned)_faces.size();};
	std::vector< Face* > _faces;
	
private:
	void loadFromFile(const std::string& filename);
	void loadFromBinaryFile(const std::string& filename);
	void loadFromTextFile(const std::string& filename);	
};

#endif